const DFT = (value, options) => {
  for (const item of options) {
    if (item.value === value) {
      return item;
    } else if (item.children) {
      const result = DFT(value, item.children);
      if (result) {
        return result;
      }
    }
  }
  return null;
};

const BFT = (value, options) => {
  let stack = options.slice(0);
  while (stack.length) {
    const item = stack.shift();
    if (item.value === value) {
      return item;
    } else if (item.children) {
      stack = stack.concat(item.children);
    }
  }
  return null;
};

export { DFT, BFT };